package Test1;
import java.util.Arrays;
class Money implements Cloneable{
    public int money;
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
class Student extends Money implements Cloneable{
    public  String name;
    public static Money m = new Money();
    public Student(String name) {
        this.name = name;
    }
    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' + '}';
    }
    @Override
    protected Object clone() throws CloneNotSupportedException {
        //只是克隆了Student对象
        Student student = (Student) super.clone();
        //克隆了Student的Money对象
        Student.m = (Money)this.m.clone();
        return student;
    }
}
public class Test2 {
    public static void main (String[] args) throws CloneNotSupportedException {
        Student student1 = new Student("张山");
        student1.m.money = 34;
        Student student2 = (Student)student1.clone();
        System.out.println(student1.m.money);
        System.out.println(student2.m.money);
        student1.m.money = 88;
        System.out.println(student1.m.money);
        System.out.println(student2.m.money);
//        students[0] = new Student("李艾");
//        students[0] = new Student("俊才");
//        students[0] = new Student("何洁");
//        students[0] = new Student("张伸");

    }
}

